package com.lingx.web.api.impl;

import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.lingx.service.LingxService;
import com.lingx.utils.Utils;
import com.lingx.web.api.IApi;
@Component
public class Api8007 extends AbstractApi implements IApi{

	@Resource
	private JdbcTemplate jdbcTemplate;
	@Resource
	private LingxService lingxService;
	@Override
	public int getApiCode() {
		return 8007;
	}
	@Override
	public String getApiName() {
		return "发布提醒消息";
	}
	@Override
	public Map<String, Object> api(Map<String, Object> params) {
		Map<String,Object> ret=IApi.getRetMap(1, "操作成功");
		this.checkIsNull(params, ret, "acceptkey","userid","content");
		String acceptkeySystem=this.lingxService.getConfigValue("lingx.message.api8007.acceptkey", UUID.randomUUID().toString());
		String content=this.getParamString(params, "content", "");
		String userid=this.getParamString(params, "userid", "");
		String acceptkey=this.getParamString(params, "acceptkey", "");
		String route_path=this.getParamString(params, "route_path", "");
		
		if(acceptkeySystem.equals(acceptkey)) {
			String time=Utils.getTime();
			this.jdbcTemplate.update("insert into tlingx_message(content,to_user_id,from_user_id,type,status,is_push,route_path,create_time,read_time) values(?,?,?,?,?,?,?,?,?)",
					content,userid,"",1,1,0,route_path,time,time);
		}
	
		return ret;
	}

}
